run:
  skip-dirs:
    - pkg/errors
    
  go: "1.22"
  timeout: 5m

linters:
  enable-all: true
  disable:
    - protogetter
    # deprecated
    - golint
    - exhaustivestruct
    - maligned
    - interfacer
    - scopelint
    - ifshort
    - varcheck
    - structcheck
    - deadcode
    - nosnakecase
    # difficult
    - paralleltest
    - ireturn
    - exhaustruct
    # ugly
    - godox
    - tagalign
    - inamedparam

linters-settings:
  dupl:
    threshold: 175

  wrapcheck:
    ignorePackageGlobs:
      - github.com/labstack/echo/*
    ignoreSigs:
      - .Errorf(
      - errors.New(
      - errors.Unwrap(
      - errors.Join(
      - .Wrap(
      - .Wrapf(
      - .WithMessage(
      - .WithMessagef(
      - .WithStack(
      - .GRPC(
      - status.Error
  depguard:
    rules:
      main:
        allow:
          - $gostd
          - github.com
          - gitverse.ru
        deny:
          - pkg: "emperror.dev/errors"
            desc: should be replaced by "github.com/pkg/errors"

  funlen:
    lines: 120

  varnamelen:
    # The longest distance, in source lines, that is being considered a "small scope." (defaults to 5)
    # Variables used in at most this many lines will be ignored.
    max-distance: 5
    min-name-length: 2
    check-receiver: false
    check-return: false
    check-type-param: false
    ignore-type-assert-ok: false
    ignore-map-index-ok: false
    ignore-chan-recv-ok: false
    ignore-names:
      - err
      - ctx
    ignore-decls:
      - ctx echo.Context
      - t testing.T
      - T any

  errcheck:
    exclude-functions:
      - (io.Closer).Close

  gci:
    custom-order: false
    sections:
      - standard # Standard section: captures all standard packages.
      - default # Default section: contains all imports that could not be matched to another section type.
      - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
      - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
  
  goconst:
    min-len: 2
    min-occurrences: 2
  
  lll:
    line-length: 140
  
  revive:
    rules:
      # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
      - name: blank-imports
      - name: context-as-argument
      - name: context-keys-type
      - name: error-return
      - name: error-strings
      - name: error-naming
      - name: if-return
      - name: increment-decrement
      - name: var-naming
      - name: var-declaration
      - name: range
      - name: receiver-naming
      - name: time-naming
      - name: unexported-return
      - name: indent-error-flow
      - name: errorf
      - name: empty-block
      - name: superfluous-else
      - name: unused-parameter
      - name: unreachable-code
      - name: redefines-builtin-id
      #
      # Rules in addition to the recommended configuration above.
      #
      - name: bool-literal-in-expr
      - name: time-equal
      - name: constant-logical-expr
      - name: receiver-naming
  
  gosec:
    excludes:
      - G307 # Deferring unsafe method "Close" on type "\*os.File"
      - G108 # Profiling endpoint is automatically exposed on /debug/pprof
  
  gocritic:
    enabled-tags:
      - diagnostic
      - experimental
      - performance
    disabled-checks:
      - appendAssign
      - dupImport # https://github.com/go-critic/go-critic/issues/845
      - evalOrder
      - ifElseChain
      - octalLiteral
      - regexpSimplify
      - sloppyReassign
      - truncateCmp
      - typeDefFirst
      - unnamedResult
      - unnecessaryDefer
      - whyNoLint
      - wrapperFunc
      - rangeValCopy
      - hugeParam

issues:
  exclude-rules:
    - text: "should not use dot imports"
      linters:
        - stylecheck
    - text: "at least one file in a package should have a package comment"
      linters:
        - stylecheck
    - text: "should have a package comment, unless it's in another file for this package"
      linters:
        - golint
    - text: "should have comment or be unexported"
      linters:
        - golint
    - path: _test\.go
      linters:
        - gosec
        - dupl
  exclude-use-default: false

output:
  print-linter-name: true